<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
include('blog-frame/header.php');
$current_url = explode('?', cpx_current_url());
$url = $current_url[0];
?>
<div id="content" class="clearfix">
<div id="main" class="col620 clearfix" role="main">
    <?php
        $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
        $args = array(
            'post_type' => 'post'
            ,'post_status' => 'publish'
             ,'posts_per_page' => -1
             // ,'paged' => $paged
        );
        $query = new WP_Query($args);
        $total_pages = $query->max_num_pages;
        ?>
    <?php
        if($query->have_posts()):
    ?>
    <?php
        while ( $query->have_posts() ) :
        $query->the_post();
        $categories = get_the_category( $id );
    ?>
    <article id="post-<?php echo $id;?>" class="post-302 post type-post status-publish format-standard hentry category-news">
        <header class="entry-header">
            <h3 class="entry-title">
                <a href="<?php echo get_permalink($id);?>" title="<?php echo $title;?>" rel="bookmark"><?php echo the_title();?></a>
            </h3>
            <div class="entry-meta">
                <span class="sep">Posted on </span>
                <time class="entry-date" datetime=""><?php echo get_the_time('Y-m-d', $id);?></time>
            </div>
            <div class="blog-social">
                <div class="blog-sharer facebook"><div class="fb-share-button" data-href="<?php echo get_permalink($id);?>" data-type="button_count"></div></div>
                <div class="blog-sharer twitter">
                    <a href="https://twitter.com/share" class="twitter-share-button" data-url="<?php echo get_permalink($id);?>" data-via="Bigsavecoupon">Tweet</a>
                    <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],
                        p=/^http:/.test(d.location)?'http':'https';
                        if(!d.getElementById(id)){js=d.createElement(s);
                        js.id=id;js.src=p+'://platform.twitter.com/widgets.js';
                        fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
                </div>
            </div>
        </header>
        <div class="entry-content post_content">
            <?php echo word_limiter((apply_filters('the_content',get_the_content($id))), 50);?>
            <a href="<?php echo get_permalink($id);?>" class="more-link">Continue reading <span class="meta-nav">→</span></a>
        </div>
        <footer class="entry-meta">
            <span class="cat-links">Posted in&nbsp;
                <?php
                    foreach ($categories as $key=>$category):
                        if($key == 0):
                ?>
                        <a href="<?php echo get_category_link($category->term_id);?>" title="View all posts in <?php echo $category->name;?>" rel="tag"><?php echo $category->name;?>&nbsp;</a>
                <?php
                        else:
                ?>
                        <a href="<?php echo get_category_link($category->term_id);?>" title="View all posts in <?php echo $category->name;?>" rel="tag"><?php echo ','. $category->name;?>,&nbsp;</a>
                <?php
                        endif;
                ?>
                <?php
                    endforeach;
                ?>
            </span>
        </footer>
    </article>
    <?php
        endwhile;
    ?>
    <?php
    /*
        
    */
        //twentythirteen_paging_nav();
                // if($total_pages != 0):
                //     pagination($total_pages,2);
                // endif;
        else:
    ?>
        <article id="post-0" class="post no-results not-found">
            <header class="entry-header">
                <h1 class="entry-title"><?php _e( 'Nothing Found', 'living-journal' ); ?></h1>
            </header><!-- .entry-header -->
        </article><!-- #post-0 -->
    <?php endif; ?>
</div>
<!-- end #main -->
<div id="sidebar" class="widget-area col300" role="complementary">
	<?php if(is_active_sidebar('cs-blog-right-sidebar')) dynamic_sidebar( 'cs-blog-right-sidebar' ); ?>
</div><!-- #secondary .widget-area -->
<?php
include('blog-frame/footer.php');
?>
